package main

import(
	"my_server_test/router"
	"my_server_test/config"
	"flag"
	"fmt"
	"github.com/gin-gonic/gin"
	"os"
	"os/signal"
	"syscall"
)

var (
	configFile=flag.String("c","conf/AppServerConfig.ini","加载配置文件")
)
func main(){
	flag.Parse()
	if !config.LoadConfigINI(*configFile){
		fmt.Println("配置文件加载失败！")
		return
	}
	/*初始化xorm*/
	//xorm.InitXorm(config.AppServerSet.MasterDsn)

	engine := gin.New()
	router.Router(engine)

	sigChan := make(chan os.Signal, 1)
		signal.Notify(sigChan, os.Interrupt, syscall.SIGUSR1)
		go func() {

			select {
			case <-sigChan:
				//model.Log.Debug("信号量来了。。。")
				fmt.Printf("信号量来了")
				//server.Close()
				//server.Close()
				//model.Log.Debug("shuted down")
				/*停止消费*/
				//nsqlx.Stop()
				/*停止生产*/
				//product.NsqProducer.Stop()
				os.Exit(-1)

			}
		}()


		err := engine.Run(config.AppServerSet.ListenPort) // listen and serve on 0.0.0.0:8080
		if err != nil {
			fmt.Println("启动失败！")
		}
}